package com.javastudy.autowiredStudy.configurationPropertiesStudy;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.concurrent.Executor;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * 这种配置看起来就舒服多了，分类很清晰
 * @author mac
 * @date 2021/9/9 12:20 下午
 */
//@Configuration
//public class ThreadPoolConf {
//    @Autowired
//    private ThreadPoolConfOfConfigurationProperties threadPoolConfOfConfigurationProperties;
//
//    @Bean
//    public Executor threadPoolExecutor(){
//        ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
//        threadPoolTaskExecutor.setCorePoolSize(threadPoolConfOfConfigurationProperties.getCorePoolSize());
//        threadPoolTaskExecutor.setMaxPoolSize(threadPoolConfOfConfigurationProperties.getMaxPoolSize());
//        threadPoolTaskExecutor.setQueueCapacity(threadPoolConfOfConfigurationProperties.getQueueCapacity());
//        threadPoolTaskExecutor.setKeepAliveSeconds(threadPoolConfOfConfigurationProperties.getKeepAliveSeconds());
//        threadPoolTaskExecutor.setThreadNamePrefix(threadPoolConfOfConfigurationProperties.getThreadNamePrefix());
//        threadPoolTaskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
//        threadPoolTaskExecutor.initialize();
//        return threadPoolTaskExecutor;
//    }
//}
